resumeObj = {
    init(){
        this.renderHead();
        this.bindEvent();
        this.getUserResumeData();
    },
        
    renderHead(){
        var phone = localStorage.phone;
        var userName = localStorage.userName;       
        $('#name').html(`
            <span >${userName}</span>
            <span class = "mt-5">${phone}</span>
            `)
    },
    bindEvent(){
    $('.btn').click(function(){
        resumeObj.addUserResume();
    })
    $('.back').click(function(){
       location.href = '../my/my.html';
    })
    },
    addUserResume(){
      if($('input').val() == ''){
        alert('请填写完整简历');
      }else{
        var phone = localStorage.phone;
        var userName = localStorage.userName;
        var userId = localStorage.userId;
        var data= {
            age:$('#age').val(),
            address:$('#address').val(),
            workAddress:$('#work-address').val(),
            workTime:$('#work-time').val(),
            name:userName,
            userId:userId,
            phone:phone,
            imgUrl:$('#head').attr('src'),
            sex:$('option:selected').text(),
            jobintention:$('#job-intention').val(),
            experience:$('#experience').val(),
            skill:$('#skill').val(),
            skselfDescriptionill:$('#self-description').val(),
            workCntent:$('#work-content').val(),

        }
        $axios.post('/userResume',data).then(function(res){
            alert('简历填写完成');
            location.href='../my/my.html'
        })
      }
    },
    getUserResumeData(){
        var user = localStorage.userId;
        console.log('user',user);
        $axios.get(`/userResume?userId=${user}`).then(function(res){   
            resumeObj.render(res.data);
        })
    },
    render(resumeData){
        console.log('data ',resumeData);
        resumeData.forEach(item => {
            $('#age').val(item.age),
            $('#work-address').val(item.address),
            $('#address').val(item.address),
            $('#work-time').val(item.workTime),
            $('option:selected').text(item.sex),
            $('#job-intention').val(item.jobintention),
            $('#experience').val(item.experience),
            $('#skill').val(item.skill),
            $('#self-description').val(item.skselfDescriptionill),
            $('#work-content').val(item.workCntent)
        });
      
    }
}
resumeObj.init();
